Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SVG files loosing transparency during conversion #3728

Merged
merged 4 commits into from
Dec 9, 2024

Conversation

nicolasbeauvais
Copy link
Contributor

Hello,

When running a media conversion against an SVG file to another file format that support transparency such as PNG or WEBP, conversions will lose any transparency and force a white background.

Two modifications were needed to make it work:

  • Convert SVG files to PNG32 instead of JPEG to avoid loosing transparency
  • Set the image background color before reading the image

I tested this change on PHP 8.3 / Imagick 1809 / ImageMagick 7.1.1-41 on Fedora Linux.

The PNG format of png32 was the one previously used before this commit, I guess 32 is good enough for most SVG use-cases.

@freekmurze freekmurze merged commit fe3f17e into spatie:main Dec 9, 2024
13 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants